package com.factors.DaiGuiCheng.aveStudyTime;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;


import java.io.IOException;

public class AveStudyTimeMapper extends Mapper<LongWritable, Text, Text,IntWritable> {

    Text outKey = new Text();
    IntWritable outValue = new IntWritable();
    protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
        if (key.get() == 0) return;

        String[] lines = value.toString().split(",");

        //2、以成绩作为key，参与分区，通过自定义分区，同一段成绩的数据到同一个分区同一个reducetask处理
        String Stime = lines[0];
        int perf  = Integer.parseInt(lines[lines.length-1]);
        //3、赋值
        outKey.set(Stime);
        outValue.set(perf);

        //4、写出去   阿拉斯加州     时间 阿拉斯加州  县 11 2
        context.write(outKey,    outValue);

    }
}
